package com.jstyle.jclife.view;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.Gravity;
import android.widget.Button;
import android.widget.TextView;

import com.jstyle.jclife.R;
import com.jstyle.jclife.adapter.HeartHistoryDetailAdapter;
import com.jstyle.jclife.model.HeartData;
import com.jstyle.jclife.utils.ScreenUtils;

import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by Administrator on 2018/9/27.
 */

public class HeatDetailDialog extends JstyleDialog {


    @BindView(R.id.tv_title_hr)
    TextView tvTitleHr;

    @BindView(R.id.RecyclerView_Detail)
    RecyclerView RecyclerViewDetail;
    @BindView(R.id.bt_exit)
    Button btExit;
    HeartHistoryDetailAdapter heartDetailAdapter;
    @BindView(R.id.tv_date_hr)
    TextView tvDateHr;
    private List<HeartData> heartData;
    String date;
    public HeatDetailDialog(@NonNull Context context) {
        super(context);

    }

    public HeatDetailDialog(@NonNull Context context, List<HeartData> heartData, String date, int themeResId) {
        super(context, themeResId);
        this.heartData = heartData;
        this.date=date;
        init(context, themeResId);

    }

    private void init(Context context, int themeResId) {
        initStyle(themeResId);
        initWidth(ScreenUtils.getScreenWidth(context));
        initGravity(Gravity.CENTER);
        setData(heartData);
        setCanceledOnTouchOutside(true);
    }


    public void setData(List<HeartData> heartData) {
        heartDetailAdapter = new HeartHistoryDetailAdapter(heartData);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        RecyclerViewDetail.setLayoutManager(linearLayoutManager);
        RecyclerViewDetail.setAdapter(heartDetailAdapter);
        tvDateHr.setText(date);
    }


    @Override
    protected void setContentView() {
        setContentView(R.layout.dialog_hr_detail);
    }


    @OnClick(R.id.bt_exit)
    public void onViewClicked() {
        dismiss();
    }
}
